import 'package:flutter/material.dart';
import 'package:flutter_xxyk/constant/routes.dart';

class CustomAppBar extends StatelessWidget {
  const CustomAppBar({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Padding(
      padding: EdgeInsets.symmetric(horizontal: 14, vertical: 15),
      child: Row(
        children: [
          InkWell(
            onTap: () {
              Navigator.of(context).pushNamed(AppRoutes.HOME);
            },
            child: _buildSquareIcon(Image.asset("assets/images/home.png")),
          ),
          Expanded(
              child: Padding(
            padding: EdgeInsets.symmetric(horizontal: 10),
            child: Text(
              "小象自习室",
              style: TextStyle(fontWeight: FontWeight.bold, fontSize: 18, overflow: TextOverflow.ellipsis),
            ),
          )),
          Row(
            children: [
              InkWell(
                onTap: () {},
                child: Padding(padding: EdgeInsets.all(5), child: _buildSquareIcon(Image.asset("assets/images/search2.png"), size: 26)),
              ),
              SizedBox(width: 10),
              InkWell(
                onTap: () {},
                child: Padding(padding: EdgeInsets.all(5), child: _buildSquareIcon(Image.asset("assets/images/smile.png"), size: 26)),
              ),
            ],
          ),
        ],
      ),
    );
  }

  SizedBox _buildSquareIcon(Widget icon, {double? size}) =>
      SizedBox.square(dimension: size ?? 41, child: AspectRatio(aspectRatio: 2, child: icon));
}
